﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HomeBudget
{
    public abstract class BudgetItem : Money, INamedItem
    {
        private string name;
        public Category Category { get; set; }
        protected BudgetItem(decimal amount, string name, Category category) : base(amount)
        {
            this.Name = name;
            this.Category = category;
        }

        public string Name
        {
            get
            {
                return this.name;
            }
            set
            {
                if (String.IsNullOrEmpty(value))
                {
                    throw new ArgumentException("Item name has to be a non-empty string.");
                }
                else
                {
                    this.name = value;
                }
            }
        }

        public override string ToString()
        {
            StringBuilder returnString = new StringBuilder();
            returnString.AppendFormat("{0}-{1}", this.Amount, this.Name);
            return returnString.ToString();
        }
    }
}
